﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using park.cn.linkit.epark;
using park.Common;

namespace park.System_Agency
{
    public partial class AgencyList : System.Web.UI.Page
    {
        ServiceList ws = new ServiceList();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["m"] != null)
            {
                Response.ContentType = "application/json";
                string m = Request.Params["m"];
                string r = "{}";
                switch (m)
                {
                    case "SearchAgency":
                        r = SearchAgency();
                        break;
                    case "AddAgency":
                        r = AddAgency();
                        break;
                    case "GetAgency":
                        r = GetAgency();
                        break;
                    case "ModifyAgency":
                        r = ModifyAgency();
                        break;
                    case "DeleteAgency":
                        r = DeleteAgency();
                        break;
                    case "ExchangeAgencyOrder":
                        r = ExchangeAgencyOrder();
                        break;

                }
                Response.Write(r);
                Response.End();
            }
            
        }

        string ExchangeAgencyOrder()
        {
            string id1 = Utils.RequestValue("id1");
            string id2 = Utils.RequestValue("id2");
            string result = @"{""success"":1 ,""msg"": ""123"" }";
            
            return result;
        }

        string DeleteAgency()
        {
            string id = Utils.RequestValue("id");
            string result = @"{""success"":1 ,""msg"": ""123"" }";
            
            return result;
        }

        string ModifyAgency()
        {
            string id = Utils.RequestValue("id");           
            string code = Utils.RequestValue("code");
            string name = Utils.RequestValue("name");
            string hasAutority = Utils.RequestValue("hasAutority");
            string result = @"{""success"":1 ,""msg"": ""123"" }";
            return result;
        }

        string GetAgency()
        {
            string id = Utils.RequestValue("id");
            string result = @"{
""id"":2
,""pid"":1
,""hasAutority"":1
,""cid"":1
,""rid"":4
,""code"":""YHN2345""
,""name"":""设备站""
,""order"":1024
}
";
            return result;
        }

        string AddAgency()
        {
            string pid = Utils.RequestValue("pid");
            string bid1 = Utils.RequestValue("bid1");
            string bid2 = Utils.RequestValue("bid2");
            string cid = Utils.RequestValue("cid");
            string rid = Utils.RequestValue("rid");
            string code = Utils.RequestValue("code");
            string name = Utils.RequestValue("name");
            string hasAutority = Utils.RequestValue("hasAutority");
            string result = @"{""success"":1 ,""msg"": ""123"" }";
            return result;
        }

        string SearchAgency()
        {
            string cid = Utils.RequestValue("cid");
            string rid = Utils.RequestValue("rid");
            string name = Utils.RequestValue("name");

            string s = @"{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":-1
,""id"":2
,""code"":""YHX3678""
,""name"":""硚口设备总站""
,""hasAutority"":1
,""order"":1024
},
{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":2
,""id"":3
,""code"":""YHX3679""
,""name"":""硚口设备分站1""
,""hasAutority"":0
,""order"":1024
},
{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":3
,""id"":10
,""code"":""YHX3679-1""
,""name"":""硚口设备分站1设备处1""
,""hasAutority"":0
,""order"":1024
},
{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":2
,""id"":5
,""code"":""YHX367a""
,""name"":""硚口设备分站2""
,""hasAutority"":1
,""order"":2048
},{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":-1
,""id"":4
,""code"":""YHX3678""
,""name"":""硚口设备总站2""
,""hasAutority"":1
,""order"":1024
},
{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":4
,""id"":30
,""code"":""YHX3679""
,""name"":""硚口设备分站12""
,""hasAutority"":0
,""order"":1024
}";

            string s1 = "";
            for (int i = 0; i < 10; i++)
            {
                s1 += s + ",";
            }

            string result = @"{
""data"":[
{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":-1
,""id"":2
,""code"":""YHX3678""
,""name"":""硚口设备总站""
,""hasAutority"":1
,""order"":1024
},
{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":2
,""id"":3
,""code"":""YHX3679""
,""name"":""硚口设备分站1""
,""hasAutority"":1
,""order"":1024
},
{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":3
,""id"":10
,""code"":""YHX3679-1""
,""name"":""硚口设备分站1设备处1""
,""hasAutority"":1
,""order"":1024
},
{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":2
,""id"":5
,""code"":""YHX367a""
,""name"":""硚口设备分站2""
,""hasAutority"":1
,""order"":2048
},{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":-1
,""id"":4
,""code"":""YHX3678""
,""name"":""硚口设备总站2""
,""hasAutority"":1
,""order"":1024
},
{
""cName"":""汉口""
,""rName"":""硚口""
,""pid"":4
,""id"":30
,""code"":""YHX3679""
,""name"":""硚口设备分站12""
,""hasAutority"":1
,""order"":1024
}
]
}
";
            result = @"{
""data"":[" + s1.Trim(',') + "]}";
            //result = ws.SearchAgency
            return result;

        }

       
    }
}